<form id="user_info" method="post">
    <div align="center">
        <div>
            <label>　用户名:</label>
            <input class="easyui-validatebox" type="text" name="username"
                   data-options="required:true"/>
        </div>
        <div style="margin-top: 10px;">
            <label for="name">　　密码:</label>
            <input id="password" class="easyui-validatebox" type="password" name="password"
                   data-options="required:true"/>
        </div>
        <div style="margin-top: 10px;">
            <label for="name">再次输入:</label>
            <input class="easyui-validatebox" type="password" name="password2"
                   data-options="required:true" validType="equals['#password']" />
        </div>

        <div style="margin-top: 10px;">
            <label for="name">用户角色:</label>
            <input  id="user_roles" class="easyui-validatebox" name="userRoles" >
        </div>
        <div align="center" style="margin-top: 10px;">
            <button href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" type="submit">保存</button>
        </div>
    </div>
</form>
<script>
    var dictInfo = $('#user_info');
    dictInfo.form({
        url: '${ctx}/user/addUser',
        onSubmit: function () {
            return dictInfo.form('validate') ? true : false;
        },
        success: function (data) {
            $.messager.show({
                title : '提示信息',
                msg : data,
                timeout : 1000 * 2
            });
            parent.$.modalDialog.openner.datagrid('reload');
            parent.$.modalDialog.handler.dialog('close');
            return false;
        }
    });
    dictInfo.submit();

    $.extend($.fn.validatebox.defaults.rules, {
        equals: {
            validator: function(value,param){
                return value == $(param[0]).val();
            },
            message: '两次密码输入不一致'
        }
    });

    $(function(){
        $("#user_roles").combobox({
            url: '${ctx}/user/findRoles',
            valueField: 'valueField',
            textField: 'textField',
            multiple:true
        });
    })
</script>